package org.terot.framework.fuzzy.setter;

import java.lang.reflect.Field;
import java.util.Collection;

import org.terot.framework.fuzzy.instance.Instantiator;

final class Setter {

	/**
	 * 
	 * @param <T>
	 * @param instances
	 * @param cl
	 * @return
	 */
	public static<T> Collection<T> setInstances(Collection<T> instances, Class<T> cl) {
	
		// iterate over each instance
		for (T obj : instances) {
			
			// loop over the objects, cause some damage 
			for (Field field : cl.getDeclaredFields()) {
				
				// TODO Maybe we shouldn't break everything?
				
				try {
					field.set(obj, Instantiator.createUnsetFuzzyInstance(cl));
				} catch (IllegalArgumentException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
		return null;
	}

}
